import request from '@/utils/request'
// import qs from 'qs'

// 辅助配置

// 增加策略
export function addInfo (params) {
  var data = fromData(params)
  return request({
    url: 'assist/addInfo',
    method: 'post',
    data
  })
}

// 导出查询的配置信息
export function exportSearchInfo (params) {
  var data = fromData(params)
  return request({
    url: 'assist/exportSearchInfo',
    method: 'post',
    data
  })
}

// 查询配置信息
export function searchInfo (params) {
  var data = fromData(params)
  return request({
    url: 'assist/searchInfo',
    method: 'post',
    data
  })
}

// 清空
export function clearAssist (params) {
  var data = fromData(params)
  return request({
    url: 'assist/clear',
    method: 'post',
    data
  })
}

// 源IPTop10统计
export function srcIpTop10 (params) {
  var data = fromData(params)
  return request({
    url: 'assist/srcIpTop10',
    method: 'post',
    data
  })
}

// 目的端口Top20统计
export function dstPortTop20 (params) {
  var data = fromData(params)
  return request({
    url: 'assist/dstPortTop20',
    method: 'post',
    data
  })
}

// 获取最大存储上限
export function getMaxCount (params) {
  var data = fromData(params)
  return request({
    url: 'assist/getMaxCount',
    method: 'post',
    data
  })
}

// 设置最大存储上限
export function setMaxCount (params) {
  var data = fromData(params)
  return request({
    url: 'assist/setMaxCount',
    method: 'post',
    data
  })
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
